package com.ggh.jinjilive.ui.home.follow;

import androidx.lifecycle.MutableLiveData;

import com.ggh.jinjilive.mobile.ResultEntity;
import com.ggh.jinjilive.mobile.home.live.LiveList;
import com.ggh.jinjilive.remotedata.InterceptObserver;
import com.ggh.jinjilive.remotedata.systemapi.SystemApiService;
import com.ggh.jinjilive.ui.BaseViewModel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class FollowViewModel extends BaseViewModel {
    //关注列表
    public MutableLiveData<List<LiveList>> mutableLiveData = new MutableLiveData<>();


    public FollowViewModel(SystemApiService apiCallInterface) {

        super(apiCallInterface);
    }


    /**
     * 关注列表
     */
    public void followList(){
        if (isRefresh) {
            page = 1;
        }else {
            page = page + 1;
        }
        Map<String, Object> paramsa = new HashMap<>();
        paramsa.put("page",page +"");
        paramsa.put("limit",pageSize);
        addSubscribe(apiCallInterface.followList(paramsa).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribeWith(new InterceptObserver<ResultEntity<List<LiveList>>>() {
                    @Override
                    public void onNextData(ResultEntity resultEntity) {
                        List<LiveList> videoListList = (List<LiveList>) resultEntity.getData();
                        mutableLiveData.setValue(videoListList);
                    }

                    @Override
                    public void onErrorNet(Throwable t, String netMsg) {

                    }
                }));
    }
}
